﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

public partial class WriteXML : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {

        string filename = Server.MapPath("temp//Data.xml");
        XmlTextWriter writer=new XmlTextWriter(filename,null);
        writer.WriteStartDocument();
        writer.WriteStartElement("People");
        writer.WriteStartElement("Person");
        writer.WriteAttributeString("FirstName",txtFirstName.Text);
        writer.WriteAttributeString("LastName",txtLastName.Text);
        writer.WriteAttributeString("Age",txtAge.Text);
        writer.WriteStartElement("Address");
        writer.WriteAttributeString("Street",txtStreet.Text);
        writer.WriteAttributeString("City",txtCity.Text);
        writer.WriteAttributeString("State",txtState.Text);
        writer.WriteAttributeString("ZipCode",txtZipCode.Text);
        writer.WriteEndElement(); //End Address
        writer.WriteStartElement("Job");
        writer.WriteAttributeString("Title",txtTitle.Text);
        writer.WriteAttributeString("Description",txtDescription.Text);
        writer.WriteEndElement();//end Job
        writer.WriteEndElement();//end Person
        writer.WriteEndElement(); //end People
        writer.WriteEndDocument();
        writer.Close();
        Response.Redirect("ReadXML.aspx");
    }
}